const demo1 = () => {
  let num = 0;
  const tableList = [1, 2, 3, 4, 5];
  const promise = () => {
    num++;
    return new Promise(reslove => {
      setTimeout(() => {
        reslove(num);
      }, 2000);
    });
  };
  (async () => {
    for await (const key of tableList) {
      const result = await promise();
      console.log("🚀 ~ forawait ~ result:", result);
    }
  })();
};
const demo2 = () => {
  const tableList = [1, 2, 3, 4, 5];
  const promise = () => {
    let num = 0;
    return {
      next: () =>
        new Promise(resolve => {
          num++;
          setTimeout(() => {
            resolve({ value: num, done: false });
          }, 2000);
        }),
    };
  };
  (async () => {
    const iterator = promise();
    for await (const key of tableList) {
      const result = await iterator.next();
      console.log("🚀 ~ forawait ~ result:", result.value);
    }
  })();
};
const demo3 = () => {
  let num = 0;
  const tableList = [1, 2, 3, 4, 5];
  const promise = () => {
    num++;
    return new Promise(reslove => {
      setTimeout(() => {
        reslove(num);
      }, 2000);
    });
  };
  (async () => {
    for (let i = 0; i < tableList.length; i++) {
      const item = tableList[i];
      const result = await promise();
      console.log("🚀 ~ result:", result);
    }
  })();
};